<?php defined('SYSPATH') or die('No direct script access.');

/**
 * Extends the main view class.
 * 
 * Changes that location of the view file to whatever is defined in
 * the configuration file.  Then calls the parser to parse the data
 * within the template.  Then Kohana continues processing as if the
 * view hadn't changed locations.
 */
class View extends View_Core {
	
	/**
	 * Construct - creates a hook into the parser.
	 * 
	 * @param  string  View name ($name)
	 * @param  string  View data ($data)
	 * @param  string  Output type - File / Return ($type)
	 * @return void
	 */
	public function __construct($name = NULL, $data = NULL, $type = NULL)
	{
		parent::__construct($name, $data, $type);
		
		// Templating system check
		if (kotemp::check_if_on())
		{
			// Change the location of the view file to render (parsed template file)
			$this->kohana_filename = kotemp::parsed_file_name($this->kohana_filename);
			
			// Perform the parse
			Parser::factory($name, $data/*, $write*/)->parse($this->kohana_filename);
		}
		// Continue processing as if NOTHING happened
		else
		{
			return;
		}
	}
}